'use strict';

/**
 * author:Administrator
 * date:2015/11/30
 * desc:用户 渲染后的图像
 */

var mongoose = require('../conn/mongoose.js');
var Schema = mongoose.Schema;

// create a schema
var __modelName = 'faceRendered';
var __collectionName = 'faceRendered';
var theModel = new Schema({
  rfaceid: {type: Number, 'default': 0, unique: true, index: true},// 渲染后的图像id
  uid: {type: String},
  ufaceid: {type: Number, 'default': 0, index: true},
  partids: [{type: String}], // 组件列表
  url: String,
  success: {type: Number, 'default': 0}, // 成功 or 失败
  rpath: String, // 相对路径
  createdAt: Date
});

theModel.pre('save', function (next) {
  if (!this.createdAt) {
    this.createdAt = new Date();
  }
  next();
});

// 指定collection name，默认是复数
module.exports = mongoose.model(__modelName, theModel, __collectionName);

